package com.sky.mapper;

import com.sky.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Options;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface UserMapper {

    @Select("select id, openid, name, phone, sex, id_number, avatar, create_time from user where openid = #{openid}")
    User getByOpenid(String openid);

    @Options(useGeneratedKeys = true,keyProperty = "id")
    @Insert("insert into user(openid,create_time) values(#{openid},#{createTime})")
    User saveUserForRegistry(User user);

    @Select("select id, openid, name, phone, sex, id_number, avatar, create_time from user where id=#{id}")
    User getByUserId(Long id);
}
